package cn.com.zhaish.thinkinjava.nio;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

public class BuferedInputFile {
	public static String read(String filename) throws IOException{
		BufferedReader in = new BufferedReader(new FileReader(filename));
		String s;
		StringBuilder sb = new StringBuilder();
		while (( s=in.readLine()) != null) {
			sb.append(s);
		}
		in.close();
		return sb.toString();
	}
	
	public static void main(String[] args) throws IOException {
		/*Properties prps = System.getProperties();
		Set set = prps.keySet();
		for (Iterator iterator = set.iterator(); iterator.hasNext();) {
			Object object = (Object) iterator.next();
			System.out.println(object +"==="+prps.get(object));
		}*/
		System.out.println(System.getProperty("user.dir")+"/src/cn/com/zhaish/thinkinjava/nio/BuferedInputFile.java");
		String path = System.getProperty("user.dir")+"/src/cn/com/zhaish/thinkinjava/nio/BuferedInputFile.java";
		File file = new File(path);
		System.out.println(read(path));
		
		///
	/*	File file = new File(BuferedInputFile.class.getName());
		System.out.println(BuferedInputFile.class.getName());
		System.out.println(read(file.getAbsolutePath()));*/
	}

}
